package com.coffee.wx.controller;

import com.coffee.wx.service.IWxFollowInfoService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 关注信息
 */
@RestController
@RequestMapping("/follow")
public class WxFollowInfoController {

    @Resource
    private IWxFollowInfoService followInfoService;

    /**
     * 获取排行榜
     *
     * @return
     */
    @GetMapping("/getRankingList")
    public String getRankingList() {
        List<Map<String, Object>> list = followInfoService.getRankingList();
        String resultMsg = "<h1>排行榜</h1><table border=\"1\"><tr><th>姓名</th><th>助力值</th></tr>";

        for (Map<String, Object> map : list) {
            resultMsg += "<tr><td>" + map.get("name") + "</td><td>" + map.get("number") + "</td></tr>";
        }
        resultMsg += "</table>";

        return resultMsg;
    }

}
